<?php
/**
 * (exporter)
 */
namespace App\Exporter\Stocking;

use App\Models\Product\ProductClassify;
use App\Util\User;
use Encore\Admin\Grid\Exporters\ExcelExporter;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
class SkuLogExporter extends ExcelExporter implements WithMapping,WithHeadings
{

    protected $fileName = '备货审批记录.csv';

    protected $headings = ['品类','站点','SKU','季节性','产品名称','备货数量','备货原因','审批数量','审批原因','备货员','审批日期'];

    public function map($model) : array
    {
        return [
            $model->skuClassify->title ?? '',
            $model->area->area ?? '',
            $model->sku->psku_code ?? '',
            ProductClassify::$_season[$model->skuClassify->season ?? 3],
            $model->sku->psku_cn ?? '',
            $model->apply_num,
            $model->apply_remark,
            $model->approval_num,
            $model->approval_remark,
            $model->seller_id ? User::getUsernameById($model->seller_id) : '',
            $model->approval_date,
        ];
    }
}
